WebTextEditor introduces innovative feature which performs auto saving based on configurable interval. Auto save operation will be invoked through AJAX callback and will be performed only when the document is modified. Developers can write their own codes to handle the auto saving operation in Save server-side event. For instances, the content can be saved to a file, database, or other storage.
Here are the steps to implement auto save in WebTextEditor:
- Set EnableAutoSave property to true.
- Set AutoSaveInterval property, default is 15 minutes.
- Handle OnSave server side event.
- Implement save mechanism in OnSave server side event.
C#
Copy Codeprotected void WebTextEditor1_Save(object sender, WebTextEditorSaveArgs e) { if (e.SaveAction == SaveAction.AutoSave) { StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath("./SampleHtml/AutoSave.html")); sw.Write(e.Content); sw.Flush(); sw.Close(); } }
The above sample will perform auto save every 15 minute and the content will be saved to file "AutoSave.html".